package com.wyp168.oss.controller;

import com.wyp168.commonutils.R;
import com.wyp168.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    @Value("${aliyun.vod.file.keyid}")
    private String keyId;

    @PostMapping
    //上传文件的方法
    public R uploadOssFile(MultipartFile file) {
        //获取上传的文件  MultipartFile
        //返回上传的oss路径
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url",url);
    }

    @GetMapping("testController")
    public String testController() {
        return keyId;
    }
}
